package cn.edu.swu.gyt.auth;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import cn.edu.swu.gyt.repo.ResultSetVisitor;

public class UserResultVisitor implements ResultSetVisitor<User> {
    @Override
    public List<User> visit(ResultSet rs) throws SQLException{
        List<User> users=new ArrayList<>();
        while (rs.next()){
            User user=new User();
            user.setId(rs.getInt("id"));
            user.setName(rs.getString("name"));
            user.setPassword(rs.getString("password"));
            user.setRole(rs.getString("role"));
            users.add(user);
        }
        return users;
    }
}
